$(document).ready(function(){
    
    $("#schedule").click(function(){        
        var name =$("#name").val();       
        if(name == ""){
            $("#name_msg").text("Please give your schedule a name!");
            $("#name_msg").css("color", "red");
            $("#name").css("border-color", "red");
            return false;
        }
    });
    
    $("#activity").click(function(){     
        var validity = true;
        var name =$("#name").val();
        var date1 =$("#date1").val();
        var date2 =$("#date2").val();
        var actual_date1 =$("#actual_date1").val();
        var actual_date2 =$("#actual_date2").val();
        var description =$("#description").val();
        if(name == ""){
            $("#name_msg").text("Please give your activity a name!");
            $("#name_msg").css("color", "red");
            $("#name").css("border-color", "red");
            validity = false;
        }
        if(date1 == ""){
            $("#date1_msg").text("Please give your activity a start date!");
            $("#date1_msg").css("color", "red");
            $("#date1").css("border-color", "red");
            validity = false;
        }
        if(date2 == ""){
            $("#date2_msg").text("Please give your activity an end date!");
            $("#date2_msg").css("color", "red");
            $("#date2").css("border-color", "red");
            validity = false;
        }
        if(actual_date1 == ""){
            $("#actual_date1_msg").text("Please give your activity an actual start date!");
            $("#actual_date1_msg").css("color", "red");
            $("#actual_date1").css("border-color", "red");
            validity = false;
        }
        if(actual_date2 == ""){
            $("#actual_date2_msg").text("Please give your activity an actual end date!");
            $("#actual_date2_msg").css("color", "red");
            $("#actual_date2").css("border-color", "red");
            validity = false;
        }
        if(description == ""){
            $("#description_msg").text("Please provide details for your activity!");
            $("#description_msg").css("color", "red");
            $("#description").css("border-color", "red");
            validity = false;
        }
        return validity;
    });
    
    $("#delete_schedule").click(function(){        
        var amt = $('input[name="schedule_id[]"]:checked').length;
        if(amt == 0){
            $("#schedule_msg").text("Please select at least one schedule to delete!");
            $("#schedule_msg").css("color", "red");
            return false;
        }
    }); 
    
    $("#delete_activity").click(function(){        
        var amt = $('input[name="student_activity_id[]"]:checked').length;
        if(amt == 0){
            $("#activity_msg").text("Please select at least one activity to delete!");
            $("#activity_msg").css("color", "red");
            return false;
        }
    }); 
    
});
